﻿<!DOCTYPE >
<html>
<head>
    <title>微街秀 > 选择区域</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" type="text/css" href="css/css.css">
    <script src="js/ajax-data.js" type="text/javascript"></script>
    <script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <style type="text/css">
        .nicksave
        {
            width: 93%;
            margin-left: auto;
            line-height: 40px;
            margin-right: auto;
            height: 40PX;
            -webkit-border-radius: 10px;
            margin-top: 20%;
            border: #F37B0B 1px solid;
            text-align: center;
        }
    </style>
</head>
<body>
    <div>
        <div class="wamtop">
            <div class="topleft" onclick="window.location.href='Makesh_4.html'">
                <img src="img/5.jpg" /></div>
            <div class="topcententxt">
                选择区域</div>
        </div>
        <div style="height: 100px; width: 90%; background: white; margin-top: 5px;margin: 20px auto 0 auto;" id="">
          
           
            <div style="margin-top:20px;">
                当前区域：<span class="area"></span>
             </div>
        </div>
        <div class="nicksave">
            <div style="color: #F37B0B; font-size: 20px;">
                <strong>重新定位</strong></div>
        </div>
    </div>
    <script>
        var area1="",area2="",area3="";
        $(document).ready(function () {
            LoadLocation();
            if (navigator.userAgent.indexOf("wjx") == -1) {
                $(".area").html("<a href='makeselectare.html'>定位失败，点击刷新</a>")
                return;
            }
            $(".nicksave").bind("click", submits);
        });

        function submits() {
            if (!islogin()) { window.location.href = 'login.html'; return; }
            if (!confirm("确定要更新定位吗?")) return;
            var param = "area1=" + area1 + "&area2=" + area2 + "&area3=" + area3;
            if (area1 == "" && area3 == "" && area3 == "") {
                Alert("定位获取失败,请重新进入页面");
                return;
            }
            AjaxStart("ajax/fc_setting.ashx?Setting", param, function (data) {
                if (data.code == 0) {
                    Alert("更新成功")
                    setTimeout(function () { window.location.href = "Makesh_4.html" }, 1000);
                }
                else
                    Alert(data.msg);
            });
        }

         //获取获取位置
        function LoadLocation() {
            if (navigator.userAgent.indexOf("wjx") == -1) {
                return;
            }
            var param = { callback: "Call_Location", isRefresh: false };
            var p = JSON.stringify(param);
            window.location.href = "callback://location?" + p;
        }

        function Call_Location(jsonStr) {
            var json = jsonStr;
            if (json != null) {
                json = JSON.parse(json);
                $(".area").html(json.address)
                area1 = json.province;
                area2 = json.city;
                area3 = json.district;

                if (area1.substring(area1.length - 1) == '省')
                    area1 = area1.substring(0, area1.length - 1);
                if (area2.substring(area2.length - 1) == "市")
                    area2 = area2.substring(0, area2.length - 1);
            }
            else
                Alert("获取定位失败");
        }
    </script>
</body>
</html>
